import React from "react";
import { Redirect } from "react-router-dom";

import { connect } from "react-redux";

class Auth extends React.Component {
  componentWillMount() {
    //is(isAuthenticated)
    //isEmpty (this.props.profile) ? fetch()
  }

  render() {
    return (
      <div>
        {this.props.isAuthenticated ? (
          this.props.children
        ) : (
          <Redirect to="/login" />
        )}
      </div>
    );
  }
}

const mapStateToProps = state => {
  // state.auth;
  return state.auth;
};

export default connect(mapStateToProps)(Auth);
